package com.bootdo.program.wallpaper.job;

import com.bootdo.oa.domain.Response;
import com.bootdo.program.wallpaper.service.WithdrawalDetailsService;
import org.quartz.Job;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.messaging.simp.SimpMessagingTemplate;
import org.springframework.stereotype.Component;

import java.util.HashMap;
import java.util.Map;

/**
 * @author guoyunfei on 2022/1/21 9:57
 * @className WithdrawalJob
 * @description TODO 提现消息提醒
 * @Version 1.0
 */

@Component
public class WithdrawalJob implements Job {

    @Autowired
    SimpMessagingTemplate template;

    @Autowired
    private WithdrawalDetailsService withdrawalDetailsService;

    @Override
    public void execute(JobExecutionContext arg0) throws JobExecutionException {

        Map<String,Object> map = new HashMap<>();
        map.put("status",1);
        int count = withdrawalDetailsService.count(map);
        if(count > 0){
            template.convertAndSend("/topic/tithdrawalJob", new Response("您有"+count+"条提现单,请及时处理" ));
        }

    }

}
